
/**
 * 获取设备信息
 */
export function getSystemInfo(){
	uni.getSystemInfo({
		success: res => {
			const modelmes = res.model
			if (modelmes.search('iPhone X') !== -1) {
				store.commit('config/setIsPhoneX', true)
			}
		}
	})
}


// 连接wifi
export function connectWifi(){
	const storeInfo = store.state.config.storeInfo
	uni.startWifi({
		success: () => {
			uni.connectWifi({
				SSID: storeInfo.FWiFiName,
				password: storeInfo.FWiFiPass,
				success: res => {
					uni.showToast({
						title: 'wifi连接成功'
					})
				},
				fail: res => {
					uni.showToast({
						title: 'wifi连接失败',
						icon: 'none'
					})
				}
			})
		}
	})
}

export function checkUpdate(){
	const updateManager = uni.getUpdateManager() // 获取更新管理器对象
	updateManager.onCheckForUpdate(res => {
		if (res.hasUpdate) {
			updateManager.onUpdateReady(() => {
				uni.showModal({
					title: '更新提示',
					content: '新版本已经准备好，点击确定重新启动',
					showCancel: false,
					success: res => {
						if (res.confirm) {
							updateManager.applyUpdate() 
						}
					}
				})
			})
			updateManager.onUpdateFailed(() => {
				wx.showModal({
					title: '提示',
					content: '检查到有新版本，但是下载失败，请检查网络设置',
					showCancel: false
				})
			})
		}
	})
}

